package com.zts.modules.sys.mapper;

import com.zts.base.data.CrudMapper;
import com.zts.modules.sys.entity.Code;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;

/**
 * Created by lzk on 2017/6/16.
 */
public interface CodeMapper extends CrudMapper<Code> {
    @Override
    @SelectProvider(type = CodeSqlProvider.class, method = "get")
    Code get(Long id);

    @Override
    @SelectProvider(type = CodeSqlProvider.class, method = "getByEntity")
    List<Code> getByEntity(Code code);

    @Override
    @SelectProvider(type = CodeSqlProvider.class, method = "getList")
    List<Code> getList(Code code, RowBounds rowBounds);

    @Override
    @InsertProvider(type = CodeSqlProvider.class, method = "insert")
    @SelectKey(statement = "SELECT CURRVAL('seq_sys_code_id')", keyProperty = "id", before = false, resultType = Long.class)
    int insert(Code code);
    @Override
    @UpdateProvider(type = CodeSqlProvider.class, method = "update")
    int update(Code code);

    @SelectProvider(type = CodeSqlProvider.class, method = "getCodeValue")
    Code getCode(@Param("cataCode") String cataCode, @Param("subCode") String subCode);

    @UpdateProvider(type = CodeSqlProvider.class, method = "updateCodeByid")
    int updateCodeByid(Code code);

    @Override
    @DeleteProvider(type = CodeSqlProvider.class, method = "delete")
    int delete(Code code);

    @DeleteProvider(type = CodeSqlProvider.class, method = "deleteCodeBycataCode")
    int deleteCodeBycataCode(Code code);

    @DeleteProvider(type = CodeSqlProvider.class, method = "deleteCodeBycataAndSub")
    int deleteCodeBycataAndSub(Code code);
}
